import { createRouter, createWebHistory } from 'vue-router';
import Index from '../views/Index.vue'
import BusinessList from '../views/BusinessList.vue'
import BusinessInfo from '../views/BusinessInfo.vue'
import Login from '../views/Login.vue'
import Orders from '../views/Orders.vue'
import UserAddress from '../views/UserAddress.vue'
import Payment from '../views/Payment.vue'
import OrderList from '../views/OrderList.vue'
import AddUserAddress from '../views/AddUserAddress.vue'
import EditUserAddress from '../views/EditUserAddress.vue'
import Register from '../views/Register.vue'
import BusinessManagement from '../views/BusinessManagement.vue'
import UpdateBusinessInfo from '../views/UpdateBusinessInfo.vue'
import InsertBusinessInfo from '../views/InsertBusinessInfo.vue'
import UpdateUserInfo from '../views/UpdateUserInfo.vue'
import ForgetPassword from '../views/ForgetPassword.vue'
import Mine from '../views/Mine.vue'
import FoodManagement from '../views/FoodManagement.vue'
import InsertFoodInfo from '../views/InsertFoodInfo.vue'
import UpdateFoodInfo from '../views/UpdateFoodInfo.vue'
import WalletManagementVue from '../views/WalletManagement.vue';
import VIPUpgradeVue from '../views/VIPUpgrade.vue';
import paymentExcludeOrdersVue from '../views/paymentExcludeOrders.vue';
import Error403 from '../components/Error403.vue'
import TransitionVue from '../views/Transition.vue';
import CreditVue from '../views/Credit.vue';
import RedPacketVue from '../views/RedPacket.vue';

const routes = [{
		path: '/',
		name: 'Home',
		component: Index
	}, {
		path: '/index',
		name: 'Index',
		component: Index
	}, {
		path: '/businessList',
		name: 'BusinessList',
		component: BusinessList
	}, {
		path: '/businessInfo',
		name: 'BusinessInfo',
		component: BusinessInfo
	}, {
		path: '/login',
		name: 'Login',
		component: Login
	}, {
		path: '/orders',
		name: 'Orders',
		component: Orders
	}, {
		path: '/userAddress',
		name: 'UserAddress',
		component: UserAddress
	}, {
		path: '/payment',
		name: 'Payment',
		component: Payment
	}, {
		path: '/orderList',
		name: 'OrderList',
		component: OrderList
	}, {
		path: '/addUserAddress',
		name: 'AddUserAddress',
		component: AddUserAddress
	}, {
		path: '/editUserAddress',
		name: 'EditUserAddress',
		component: EditUserAddress
	}, {
		path: '/register',
		name: 'Register',
		component: Register
	}, {
		path: '/businessManagement',
		name: 'BusinessManagement',
		component: BusinessManagement
	}, {
		path: '/updateBusinessInfo',
		name: 'UpdateBusinessInfo',
		component: UpdateBusinessInfo
	}, {
		path: '/insertBusinessInfo',
		name: 'InsertBusinessInfo',
		component: InsertBusinessInfo
	}, {
		path: '/updateUserInfo',
		name: 'UpdateUserInfo',
		component: UpdateUserInfo
	}, {
		path: '/forgetPassword',
		name: 'ForgetPassword',
		component: ForgetPassword
	}, {
		path: '/mine',
		name: 'Mine',
		component: Mine
	}, {
		path: '/foodManagement',
		name: 'FoodManagement',
		component: FoodManagement
	}, {
		path: '/insertFoodInfo',
		name: 'InsertFoodInfo',
		component: InsertFoodInfo,
	}, {
		path: '/updateFoodInfo',
		name: 'UpdateFoodInfo',
		component: UpdateFoodInfo
	}, {
		path: '/walletManagement',
		name: 'WalletManagement',
		component: WalletManagementVue
	}, {
		path: '/vipUpgrade',
		name: 'VIPUpgrade',
		component: VIPUpgradeVue
	}, {
		path: '/paymentExcludeOrders',
		name: 'PaymentExcludeOrders',
		component: paymentExcludeOrdersVue
	},{
	    path: '/error403',
	    name: 'Error403',
	    component: Error403
	}, {
		path: '/transition',
		name: 'Transition',
		component: TransitionVue
	}, {
		path: '/credit',
		name: 'Credit',
		component: CreditVue
	}, {
		path: '/redPacket',
		name: 'RedPacket',
		component: RedPacketVue
	}

]

//解决重复路由报异常问题
const originalPush = createRouter.prototype.push;
createRouter.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err)
}

const router = createRouter({
	history: createWebHistory(process.env.BASE_URL),
	routes
})

export default router
